package com.xbq.exceleditor.ui

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.gyf.immersionbar.ktx.immersionBar
import com.xbq.exceleditor.R
import com.xbq.exceleditor.databinding.ActivityLoginBinding
import com.xbq.xbqsdk.component.activity.VBActivity
import dagger.hilt.android.AndroidEntryPoint

/**
 * Author: liaohaiping
 * Time: 2020-10-30
 * Description:
 */
@AndroidEntryPoint
class LoginActivity : VBActivity<ActivityLoginBinding>() {
    val fragments = mutableListOf<Fragment>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        immersionBar {
            fitsSystemWindows(true,R.color.white)
            statusBarDarkFont(true)
        }
        fragments.add(LoginFragment())
        fragments.add(RegisterFragment())

        binding.viewPager.isUserInputEnabled=false
        binding.viewPager.offscreenPageLimit = 2
        binding.viewPager.adapter = object:FragmentStateAdapter(this){
            override fun getItemCount(): Int {
                return fragments.size
            }

            override fun createFragment(position: Int): Fragment {
                return fragments[position]
            }

        }
    }

    fun showLogin(){
        binding.viewPager.setCurrentItem(0,false)
    }

    fun showRegister(){
        binding.viewPager.setCurrentItem(1,false)
    }


    override fun onBackPressed() {
    }
}